import matplotlib.pyplot as plt


def vis(b:int,tensor1,tensor2,name,base_dir='./vis/'):
    C = tensor1.size(1)
    fig, axes = plt.subplots(C, 1, figsize=(10, 5*C))

    for c in range(C):
        axes[c].plot(tensor1[b, c].cpu().numpy(), label='pred')
        axes[c].plot(tensor2[b, c].cpu().numpy(), label='target')
        axes[c].set_title(f'Channel {c}')
    axes[c].legend()
    plt.tight_layout()
    plt.savefig(f'{base_dir}/{name}')
    plt.close()
